#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str;
    cin >> str;

    int left = 0;
    int right1 = str.size() - 2, right2 = str.size() - 1;
    int max = 0;
    while (left < right1 || left < right2)
    {
        if (max != str.size() && str[left] != str[right1]) max = str.size() - 1;
        if (str[left] != str[right2])
        {
            max = str.size();
            break;
        }
        left++;
        right1--;
        right2--;
    }
    cout << max << endl;
    return 0;
}